package com.ikas.ai.server.module.costTime;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ikas.ai.server.module.instance.model.DorisWorkInstanceStepCost;
import com.ikas.ai.server.module.instance.model.DorisWorkInstanceStepDetailCost;
import com.ikas.ai.server.module.instance.service.DorisWorkInstanceStepCostService;
import com.ikas.ai.server.module.instance.service.DorisWorkInstanceStepDetailCostService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class testCosttime {

    @Autowired
    DorisWorkInstanceStepCostService dorisWorkInstanceStepCostService;
    @Autowired
    DorisWorkInstanceStepDetailCostService dorisWorkInstanceStepDetailCostService;

    @Test
    public void testShortArray(){
        String machineNo = "U01";
        String wfName = "TB26";
        String stepName = "step1";
        String meteCode = "1PAC10_AP702_DI_ON";
        String stepCode = "1CRK00_EB260_XS_11";

//        dorisWorkInstanceStepDetailCostService.computeAvgCostTime(machineNo,wfName,stepName,meteCode,100L);
//        dorisWorkInstanceStepCostService.computeAvgDelay(machineNo,wfName,stepName,stepCode,100L);
    }

    @Test
    public void testInsertCostTime(){
        String stepName = "step2";
        String machineNo = "U01";
        String meteCode = "1MFA20_AA845_DO_O";
        String wfName = "TB30";

        List<Long> times = new ArrayList<>();
        times.add(10000L);

        DorisWorkInstanceStepDetailCost dorisWorkInstanceStepDetailCost = new DorisWorkInstanceStepDetailCost()
                .setCostTimeArray(times)
                .setAvgCostTime(100L)
                .setStepName(stepName)
                .setMachineNo(machineNo)
                .setMeteCode(meteCode)
                .setWfName(wfName)
                .setId(1727244556013805569L);
//        dorisWorkInstanceStepDetailCostService.save(dorisWorkInstanceStepDetailCost);

        DorisWorkInstanceStepCost dorisWorkInstanceStepCost = new DorisWorkInstanceStepCost()
                .setDelayArray(times)
                .setAvgDelay(1000L)
                .setStepName(stepName)
                .setMachineNo(machineNo)
                .setMeteCode(meteCode)
                .setWfName(wfName)
                .setId(1727244556013805569L);
        dorisWorkInstanceStepCostService.save(dorisWorkInstanceStepCost);

    }
}
